home *** CD-ROM | disk | FTP | other *** search
- Program DlgHelpx;
-
- { Sample App using a message filter to create context sensitive
- help in a dialog. This is a very minimal implementation, used
- mainly to demostrate the creation of a Windows hook. Enhancements
- are left to the imagination of the programmer. }
-
- { Written: 7/18/91
- By: Pat Ritchey CIS ID: [70007,4660]
- Changed: 18/05/93
- By: Michael Denzlein CIS ID [100120,2601]}
-
- uses WinTypes,WinProcs,OWindows,ODialogs,DlgHelp;
-
- {$R DLGHELP.RES}
-
- const
- id_Name = 101;
- id_Address = 102;
- id_City = 103;
- id_state = 104;
- id_zip = 105;
- cm_Open = 101;
- cm_Close = 102;
- cm_Quit = 103;
- cm_AddCust = 201;
-
-
- {*************************************************************************}
- {************************ Filter *****************************************}
- {*************************************************************************}
-
- Const
- id_Help = 998;
-
- {*************************************************************************}
- {************************ Dialog *****************************************}
- {*************************************************************************}
-
- Type
- PHelpDialog = ^THelpDialog;
- THelpDialog = object(TDialog)
- Destructor Done; virtual;
- Procedure SetupWindow; virtual;
- Procedure Help(var Msg : TMessage);
- virtual id_First + id_Help;
- end;
-
- Procedure THelpDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
- InstallFilter(HWindow, id_Help);
- end;
-
- Destructor THelpDialog.Done;
- begin
- RemoveFilter;
- TDialog.Done;
- end;
-
- procedure THelpDialog.Help(var Msg: TMessage);
- var
- HelpText : Pchar;
- { This sample Help method simply uses a message box. It could
- be modified to call the built in WINHELP facilities }
- begin
- { Msg.lParamLo contains the window handle of the window with focus }
- DisableHelp;
- case GetDlgCtrlID(MSg.lParamLo) of
- id_name : HelpText := 'Enter Customer''s full name';
- id_Address : HelpText := 'Enter Full street address';
- id_City : HelpText := 'Enter City name';
- id_State : HelpText := 'Enter State Abbreviation';
- id_Zip : HelpText := 'Enter 5 or 9 digit Zip code';
- id_OK : HelpText := 'Press to add customer';
- id_Cancel : HelpText := 'Press to cancel this entry';
- id_Help : HelpText := 'Press F1 to get help for a specific field';
- else
- HelpText := 'Unknown Field';
- end;
- MessageBox(hWindow, HelpText, 'Help', mb_Ok);
- EnableHelp;
- end;
-
- {*************************************************************************}
- {************************ Window *****************************************}
- {*************************************************************************}
-
- type
- PMyWindow = ^TMyWindow;
- TMyWindow = object(TWindow)
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- Procedure CMAddCust(var MSg : TMessage);
- virtual cm_first + cm_AddCust;
- Procedure CMQuit(var Msg : TMEssage);
- virtual cm_first + cm_Quit;
- end;
-
- constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- TWindow.Init(AParent, ATitle);
- Attr.Menu := LoadMenu(HInstance,'DLGHELP');
- end;
-
- Procedure TMyWindow.CMAddCust(Var Msg : TMessage);
- begin
- Application^.ExecDialog(New(PHelpDialog,Init(@Self,'DLGHELP')));
- end;
-
- PRocedure TMyWindow.CMQuit;
- begin
- PostQuitMEssage(0);
- end;
-
- {*************************************************************************}
- {************************ Application ************************************}
- {*************************************************************************}
-
- type
- TMyApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- procedure TMyApplication.InitMainWindow;
- begin
- MainWindow := New(PMyWindow, Init(nil, 'Sample Help Context'));
- end;
-
- var
- MyApp : TMyApplication;
-
- begin
- MyApp.Init('DLGHELP');
- MyApp.Run;
- MyApp.Done;
- end.
-